package com.yunxi.controller.finance;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.finance.pojo.RebateCommissionQueryReqVO;
import com.yunxi.finance.pojo.RebateCommissionUpdateReqVO;
import com.yunxi.finance.service.RebateCommissionDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 固定返利表 前端控制器
 * </p>
 *
 * @author 
 * @since 2019-09-16
 */
@RestController
@RequestMapping("/admin/rebatecommission")
@Api(tags = "pms:rebatecommission", description = "固定返利表接口")
public class RebateCommissionController {
 private static final Logger logger = LoggerFactory.getLogger(RebateCommissionController.class);

 @Autowired
 RebateCommissionDubboService rebateCommissionDubboService;

 @GetMapping("/page")
 @ApiOperation(value = "查询固定返利表分页")
 public ApiResult page(RebateCommissionQueryReqVO rebateCommissionVO, Integer pageNum, Integer pageSize) throws Exception {
  return ResponseUtil.ok(rebateCommissionDubboService.findPageByVO(rebateCommissionVO,pageNum,pageSize));
 }

@GetMapping("/queryRebateCommission")
   @ApiOperation(value = "查询固定返利表列表")
   public ApiResult queryRebateCommission(RebateCommissionQueryReqVO rebateCommissionVO) throws Exception {
      return ResponseUtil.ok(rebateCommissionDubboService.listByVo(rebateCommissionVO));
   }

 @GetMapping("/load")
 @ApiOperation(value = "读取单个固定返利表")
 public ApiResult load(RebateCommissionQueryReqVO rebateCommissionVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      return ResponseUtil.ok(rebateCommissionDubboService.getById(rebateCommissionVO.getRebateId()));
}

 @PostMapping("/save")
 @ApiOperation(value = "保存固定返利表信息")
 public ApiResult save(@RequestBody RebateCommissionQueryReqVO rebateCommissionVO, @CurrentUser LoginInfo loginInfo) throws Exception {
    rebateCommissionDubboService.saveOrUpdate(rebateCommissionVO);
    return ResponseUtil.ok("success");
}

@PostMapping("/updateBatch")
@ApiOperation(value = "批量修改固定返利表信息")
public ApiResult updateBatch(@RequestBody RebateCommissionUpdateReqVO vo,@CurrentUser LoginInfo loginInfo){
    rebateCommissionDubboService.updateBatch(vo);
    return ResponseUtil.ok("success");
}

 @PostMapping("/del")
 @ApiOperation(value = "删除固定返利表")
 public ApiResult del(@RequestBody List<RebateCommissionQueryReqVO> rebateCommissionVOList) throws Exception {
    rebateCommissionDubboService.removeByListVo(rebateCommissionVOList);
    return ResponseUtil.ok("success");
 }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(rebateCommissionDubboService.findMapByList(params));
}*/
}
